from abc import ABCMeta, abstractmethod
from typing import List, Dict

from hj_dataset_devkit import Obstacle, Scene

from components.obj_detector import *
from components.obj_tracker import *

__all__ = ['build_component', 'ObjLabeler', 'ObjAutoLabeling']

def build_component(name: str, kwargs: dict):
    return eval(name)(**kwargs)

class ObjLabeler(metaclass=ABCMeta):
    @abstractmethod
    def __init__(self) -> None:
        pass

    @abstractmethod
    def process(self, scene: Scene) -> Dict[int, List[Obstacle]]:
        pass

class ObjAutoLabeling():
    def __init__(self, config: dict) -> None:
        self.labeler: ObjLabeler = build_component(config['labeler_name'],
                                                   config['labeler_kwargs'])

    def label_scene(self, scene: Scene) -> Dict[int, List[Obstacle]]:
        return self.labeler.process(scene)
